package com.bizframework.springhb.support.serialization.xstream;

//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.HashSet;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;

import com.bizframework.springhb.support.serialization.xstream.converter.HibernateCollectionConverter;
import com.bizframework.springhb.support.serialization.xstream.converter.HibernateMapConverter;
import com.bizframework.springhb.support.serialization.xstream.converter.HibernateProxyConverter;

import com.bizframework.core.serialization.xstream.XStreamObjectXMLSerializer;

public class XStreamHibernateObjectXMLSerializer extends XStreamObjectXMLSerializer {

	public XStreamHibernateObjectXMLSerializer() {
		super();
//		XStream xStream = new XStream() {
//		    protected MapperWrapper wrapMapper(MapperWrapper next) {
//		        return new HibernateMapper(next);
//		    }
//		};
		                       
		registerConverter(new HibernateCollectionConverter(xStream.getMapper()));
		registerConverter(new HibernateMapConverter(xStream.getMapper()));
		registerConverter(new HibernateProxyConverter(xStream.getMapper(), xStream.getReflectionProvider()));
		
//		addDefaultImplementation(HashMap.class, java.util.Map.class);
//		addDefaultImplementation(HashSet.class, java.util.Set.class);
//		addDefaultImplementation(ArrayList.class, java.util.List.class);
		
		addDefaultImplementation(HashMap.class, org.hibernate.collection.PersistentMap.class);
		addDefaultImplementation(HashSet.class, org.hibernate.collection.PersistentSet.class);
		addDefaultImplementation(ArrayList.class, org.hibernate.collection.PersistentList.class);
		addDefaultImplementation(ArrayList.class, org.hibernate.collection.PersistentBag.class);
		
		
//		addDefaultImplementation(HashMap.class, org.hibernate.collection.PersistentMap.class);
//		addDefaultImplementation(HashSet.class, org.hibernate.collection.PersistentSet.class);
//		addDefaultImplementation(org.hibernate.collection.PersistentList.class, ArrayList.class);
//		addDefaultImplementation(org.hibernate.collection.PersistentBag.class, ArrayList.class);
	}
}